package com.microcity.autocomponent;

import android.app.Application;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.microcity.autocomponent.autoview.Toaster;

/**
 * User: yaodong(1126220529@qq.com)
 * Date: 2017-07-13
 * Time: 11:19
 * Description:
 * Update:
 */

public class App extends Application {

    private static App instance;

    public static App getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        initToast();
    }

    private void initToast() {
        Toaster.get().initToastBulder(new Toaster.ToastBuilder() {
            @Override
            public Toast buildToast(Toast toast, String msg) {
                View inflate = LayoutInflater.from(instance).inflate(R.layout.common_custom_toast, null);
                TextView textView = (TextView) inflate.findViewById(R.id.toast_tv);
                textView.setText(msg);
                toast.setView(inflate);
                return toast;
            }

            @Override
            public void setText(Toast toast, String msg) {
                TextView tv = (TextView) toast.getView().findViewById(R.id.toast_tv);
                tv.setText(msg);
            }
        });
    }

}
